package com.boang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boang.entity.PO.Owner;
import com.boang.entity.VO.OwnerVO;
import com.boang.mapper.OwnerMapper;
import com.boang.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 22567
 * @description 针对表【owner(业主表)】的数据库操作Service实现
 * @createDate 2025-03-04 18:14:25
 */
@Service
public class OwnerServiceImpl extends ServiceImpl<OwnerMapper, Owner> implements OwnerService {
    @Autowired
    private  OwnerMapper ownerMapper;

    public List<Owner> queryOwners(OwnerVO queryDTO) {
        LambdaQueryWrapper<Owner> wrapper = new LambdaQueryWrapper<>();

        // 精确查询
        wrapper.eq(queryDTO.getOwnerId() != null, Owner::getOwnerId, queryDTO.getOwnerId());
        wrapper.eq(StringUtils.isNotBlank(queryDTO.getBuildingNumber()), Owner::getBuildingNumber, queryDTO.getBuildingNumber());
        wrapper.eq(StringUtils.isNotBlank(queryDTO.getIdNumber()), Owner::getIdNumber, queryDTO.getIdNumber());

        // 模糊查询
        wrapper.like(StringUtils.isNotBlank(queryDTO.getName()), Owner::getName, queryDTO.getName());
        wrapper.like(StringUtils.isNotBlank(queryDTO.getContact()), Owner::getContact, queryDTO.getContact());
        wrapper.like(StringUtils.isNotBlank(queryDTO.getMemberName()), Owner::getMemberName, queryDTO.getMemberName());
        wrapper.like(StringUtils.isNotBlank(queryDTO.getMemberPhone()), Owner::getMemberPhone, queryDTO.getMemberPhone());

        return ownerMapper.selectList(wrapper);
    }
}






